const dayjs = require('dayjs');

const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
class TimeHelper {
  timestampToDate(timestamp) {
    if (!timestamp) return '';
    return dayjs(timestamp).format('YYYY-MM-DD');
  }

  timestampToDateTime(timestamp) {
    if (!timestamp) return '';
    return dayjs(timestamp).format('YYYY-MM-DD HH:mm:ss');
  }

  timestampToWeek(timestamp) {
    const dayOfWeekNumber = dayjs(timestamp).day();
    return dayNames[dayOfWeekNumber];
  }
}

const instance = new TimeHelper();
module.exports = instance;
